IF exists(SELECT * FROM dbo.sysobjects WHERE name='KlasRooster' AND xtype='V') 
BEGIN
	DROP VIEW KlasRooster
END
GO

create view KlasRooster
as

select  distinct h.*,
	ma.deLeraar as maLeraar,
	di.deLeraar as diLeraar,
	wo.deLeraar as woLeraar,
	do.deLeraar as doLeraar,
	vr.deLeraar as vrLeraar

from hulpKLasRooster as h
left outer join (select * from rooster as r where deDag='ma')as ma
on h.Uur=ma.hetUur and h.deKLas=ma.deKlas 
left join (select * from rooster as r where deDag='di')as di
on h.Uur=di.hetUur and h.deKlas=di.deKlas
left join (select * from rooster as r where deDag='wo')as wo
on h.Uur=wo.hetUur and h.deKlas=wo.deKlas 
left join (select * from rooster as r where deDag='do')as do
on h.Uur=do.hetUur and h.deKlas=do.deKlas 
left join (select * from rooster as r where deDag='vr')as vr
on h.Uur=vr.hetUur and h.deKlas=vr.deKlas